package top.fullj.remoting.consumer;

import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;

/**
 * @author bruce.wu
 * @since 2022/2/14 10:25
 */
public class ClientStub implements InvocationHandler {

    private final Invocation invocation;

    public ClientStub() {
        this.invocation = Invocation.getInstance();
    }

    @Override
    public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
        InvokeContext ctx = new InvokeContext();
        ctx.setInvokeMethod(method);
        ctx.setInvokeArgs(args);
        return invocation.invoke(ctx);
    }

}
